/**
* 上海中赢金融信息服务有限公司
* Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
* 
*/ 
package com.chinazyjr.framework.common.zookeeper;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * 
 * <b>Description：</b> zk命名空间命名 <br/>
 * <b>ClassName：</b> ZKNameSpaceEnum <br/>
 * <b>@author：</b> jackyshang <br/>
 * <b>@date：</b> 2016年7月12日 下午3:24:23 <br/>
 * <b>@version: </b> <br/>
 */
public enum ZKNameSpaceEnum {

   MONITOR_API("服务监控", "monitor-api"), 
   MONITOR_CACHE("缓存监控", "monitor-cache"),
   DSC_JOB("调度job", "job"),
   ;
    

    /**
     * 存贮值
     */
    private String value;

    /**
     * 显示值
     */
    private String label;

    private ZKNameSpaceEnum(String label, String value) {
        this.value = value;
        this.label = label;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public static ZKNameSpaceEnum getEnum(String value) {
        ZKNameSpaceEnum resultEnum = null;
        ZKNameSpaceEnum[] enumAry = ZKNameSpaceEnum.values();
        for (int i = 0; i < enumAry.length; i++) {
            if (enumAry[i].getValue() == value) {
                resultEnum = enumAry[i];
                break;
            }
        }
        return resultEnum;
    }

    public static Map<String, Map<String, Object>> toMap() {
        ZKNameSpaceEnum[] ary = ZKNameSpaceEnum.values();
        Map<String, Map<String, Object>> enumMap = new HashMap<String, Map<String, Object>>();
        for (int num = 0; num < ary.length; num++) {
            Map<String, Object> map = new HashMap<String, Object>();
            String key = String.valueOf(getEnum(ary[num].getValue()));
            map.put("value", String.valueOf(ary[num].getValue()));
            map.put("label", ary[num].getLabel());
            enumMap.put(key, map);
        }
        return enumMap;
    }

    public static Set<String> getValues() {
        ZKNameSpaceEnum[] ary = ZKNameSpaceEnum.values();
        Set<String> reSet = new HashSet<String>();
        for (int num = 0; num < ary.length; num++) {
            reSet.add(String.valueOf(ary[num].getValue()));
        }
        return reSet;
    }
    

}
